package org.jeeasy.common.core.base;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.dromara.autotable.annotation.mysql.MysqlTypeConstant;
import org.dromara.mpe.annotation.InsertFillData;
import org.dromara.mpe.annotation.InsertFillTime;
import org.dromara.mpe.annotation.InsertUpdateFillData;
import org.dromara.mpe.annotation.InsertUpdateFillTime;
import org.dromara.mpe.annotation.handler.IAutoFillHandlerForBaseEntity;
import org.dromara.mpe.autotable.annotation.Column;
import org.dromara.mpe.autotable.annotation.ColumnId;
import org.jeeasy.common.core.base.convert.BaseDO;

import java.io.Serializable;
import java.time.LocalDateTime;

@Data
@EqualsAndHashCode(callSuper = true)
public class BaseEntity<T extends Model<T> & BaseDO<T>> extends Model<T> implements BaseDO<T>, Serializable {

    @ColumnId(mode = IdType.ASSIGN_ID, length = 26, comment = "ID")
    protected String id;

    @InsertFillTime
    @Column(comment = "创建时间")
    protected LocalDateTime createTime;

    @Column(comment = "创建人", length = 24)
    @InsertFillData(IAutoFillHandlerForBaseEntity.class)
    protected String createBy;

    @InsertUpdateFillTime
    @Column(comment = "修改时间")
    protected LocalDateTime updateTime;

    @Column(comment = "修改人", length = 24)
    @InsertUpdateFillData(IAutoFillHandlerForBaseEntity.class)
    protected String updateBy;

    @TableLogic
    @Column(comment = "删除标记", length = 1, type = MysqlTypeConstant.TINYINT, defaultValue = "0")
    protected Integer delFlag;
}
